package ch.zbw.pra.sysventory.domain.visualisation;

import java.util.ArrayList;
import java.util.List;

import ch.zbw.pra.sysventory.domain.model.Processor;

public class VisuControllProcessor extends AVisuControll implements IVisuControll<Processor> {

	private boolean prozessorName;
	private boolean prozFamily;
	private boolean anzKerne;
	private boolean clock;

	public VisuControllProcessor() {
		super();
	}

	public boolean isProzessorName() {
		return this.prozessorName;
	}

	public void setProzessorName(boolean prozessorName) {
		this.prozessorName = prozessorName;
		updateObserver();
	}

	public boolean isProzFamily() {
		return this.prozFamily;
	}

	public void setProzFamily(boolean prozFamily) {
		this.prozFamily = prozFamily;
		updateObserver();
	}

	public boolean isAnzKerne() {
		return this.anzKerne;
	}

	public void setAnzKerne(boolean anzKerne) {
		this.anzKerne = anzKerne;
		updateObserver();
	}

	public boolean isClock() {
		return this.clock;
	}

	public void setClock(boolean clock) {
		this.clock = clock;
		updateObserver();
	}

	public void addDataToRow(List<Processor> data, List<List<String>> row) {
		for (int i = 0; i < data.size(); i++) {
			Processor cpu = data.get(i);
			if (isProzessorName()) {
				row.add(makeProcessorNameList(cpu));
			}
			if (isProzFamily()) {
				row.add(makeProcessorFamilyList(cpu));
			}

			if (isAnzKerne()) {
				row.add(makeProcessorCoresList(cpu));
			}

			if (isClock()) {
				row.add(makeProcessorClockSpeedList(cpu));
			}
		}
	}

	public void addDataToColumn(List<String> data) {
		if (isProzessorName()) {
			data.add("Prozessor Name");
		}
		if (isProzFamily()) {
			data.add("CPU Family");
		}
		if (isAnzKerne()) {
			data.add("Anzahl Kerne");
		}
		if (isClock()) {
			data.add("CPU Takt in Ghz");
		}
	}

	private List<String> makeProcessorNameList(Processor cpu) {
		List<String> data = new ArrayList<String>();
		data.add(cpu.getNameProcessor());
		return data;
	}

	private List<String> makeProcessorFamilyList(Processor cpu) {
		List<String> data = new ArrayList<String>();
		data.add(cpu.getFamilyProcessor());
		return data;
	}

	private List<String> makeProcessorCoresList(Processor cpu) {
		List<String> data = new ArrayList<String>();
		data.add(cpu.getCoresProcessor() + "");
		return data;
	}

	private List<String> makeProcessorClockSpeedList(Processor cpu) {
		List<String> data = new ArrayList<String>();
		data.add(cpu.getClockProcessor() + "");
		return data;
	}

	public void restoreTo(boolean value) {
		this.prozessorName = value;
		this.prozFamily = value;
		this.anzKerne = value;
		this.clock = value;
	}
}
